/*
 * kmp_version.h -- version number for this release
 * $Revision: 42181 $
 * $Date: 2013-03-26 15:04:45 -0500 (Tue, 26 Mar 2013) $
 */

/* <copyright>
    Copyright (c) 1997-2013 Intel Corporation.  All Rights Reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:

      * Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.
      * Redistributions in binary form must reproduce the above copyright
        notice, this list of conditions and the following disclaimer in the
        documentation and/or other materials provided with the distribution.
      * Neither the name of Intel Corporation nor the names of its
        contributors may be used to endorse or promote products derived
        from this software without specific prior written permission.

    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

</copyright> */

#ifdef _MSC_VER
#pragma once
#endif

#ifndef KMP_VERSION_H
#define KMP_VERSION_H

#include "kmp_os.h"
#include "stdint.h"

#ifndef KMP_VERSION_MAJOR
#define KMP_VERSION_MAJOR XOMP_VERSION_MAJOR
#endif
#ifndef KMP_VERSION_MINOR
#define KMP_VERSION_MINOR XOMP_VERSION_MINOR
#endif
#ifndef KMP_VERSION_BUILD
#define KMP_VERSION_BUILD XOMP_VERSION_BUILD
#endif
#ifndef KMP_BUILD_DATE
#define KMP_BUILD_DATE XOMP_BUILD_DATE
#endif

#ifndef KMP_BUILD_YYYY
#define KMP_BUILD_YYYY XOMP_BUILD_YYYY
#endif
#ifndef KMP_BUILD_DDMM
#define KMP_BUILD_DDMM XOMP_BUILD_DDMM
#endif

#ifndef KMP_VERSION_NUM
#define KMP_VERSION_NUM XOMP_VERSION_NUM
#endif

#ifndef KMP_VERSIONSTR
#define KMP_VERSIONSTR XOMP_VERSIONSTR
#endif

#ifndef KMP_VERSION_STR
#define KMP_VERSION_STR XOMP_VERSION_STR
#endif

#ifndef KMP_LIB_NAME
#define KMP_LIB_NAME XOMP_LIB_NAME
#endif

#ifndef KMP_FILE
#define KMP_FILE XOMP_FILE
#endif

#ifndef KMP_LIBRARY_FILE
#define KMP_LIBRARY_FILE KMP_FILE
#endif

#ifdef __cplusplus
EXTERN_C_BEGIN
#endif // __cplusplus

// Helper macros to convert value of macro to string literal.
#define _stringer( x ) #x
#define stringer( x )  _stringer( x )

// Detect compiler.
#if XOMP_ICC
#if   __INTEL_COMPILER == 1010
#define KMP_COMPILER "Intel C++ Compiler 10.1"
#elif __INTEL_COMPILER == 1100
#define KMP_COMPILER "Intel C++ Compiler 11.0"
#elif __INTEL_COMPILER == 1110
#define KMP_COMPILER "Intel C++ Compiler 11.1"
#elif __INTEL_COMPILER == 1200
#define KMP_COMPILER "Intel C++ Compiler 12.0"
#elif __INTEL_COMPILER == 1210
#define KMP_COMPILER "Intel C++ Compiler 12.1"
#elif __INTEL_COMPILER == 1300
#define KMP_COMPILER "Intel C++ Compiler 13.0"
#elif __INTEL_COMPILER == 1310
#define KMP_COMPILER "Intel C++ Compiler 13.1"
#elif __INTEL_COMPILER == 1400
#define KMP_COMPILER "Intel C++ Compiler 14.0"
#elif __INTEL_COMPILER == 1410
#define KMP_COMPILER "Intel C++ Compiler 14.1"
#elif __INTEL_COMPILER == 9999
#define KMP_COMPILER "Intel C++ Compiler mainline"
#else
#pragma error "add your icc compiler version "
#endif
#elif XOMP_CLANG
#define KMP_COMPILER "Clang " stringer( __clang_major__ ) "." stringer( __clang_minor__ )
#elif XOMP_GCC
#define KMP_COMPILER "GCC " stringer( __GNUC__ ) "." stringer( __GNUC_MINOR__ )
#elif defined XOMP_VC
#   if XOMP_VC == 1200
#		define KMP_COMPILER "Microsoft Visual C++ 6"
#   elif XOMP_VC == 1300
#		define KMP_COMPILER "Microsoft Visual C++ 7"
#   elif XOMP_VC == 1400
#		define KMP_COMPILER "Microsoft Visual C++ 8"
#   elif XOMP_VC == 1500
#		define KMP_COMPILER "Microsoft Visual C++ 9"
#   elif XOMP_VC == 1600
#		define KMP_COMPILER "Microsoft Visual C++ 10"
#   elif XOMP_VC == 1700
#		define KMP_COMPILER "Microsoft Visual C++ 11"
#   elif XOMP_VC == 1800
#		define KMP_COMPILER "Microsoft Visual C++ 12"
#	else
#pragma error "add your vc compiler version "
#	endif
#endif
#ifndef KMP_COMPILER
#pragma error "Unknown compiler"
#define KMP_COMPILER "unknown compiler"
#endif

#if _XBOX_ONE
#		undef KMP_ARCH_STR 
#		define KMP_ARCH_STR "XOne"
#elif (_M_IX86) || (_WIN32) && !(_WIN64)
#		undef KMP_ARCH_STR
#		define KMP_ARCH_STR "x86"
#elif (_M_X64) || (_WIN64)
#		undef KMP_ARCH_STR
#		define KMP_ARCH_STR "x86_64"
#elif _M_PPC
#		undef KMP_ARCH_STR
#		define KMP_ARCH_STR "X360"
# elif _M_ARM
#		undef KMP_ARCH_STR
#		define KMP_ARCH_STR "Arm"
#elif KMP_MIC2
#		undef KMP_ARCH_STR
#		define KMP_ARCH_STR "MIC2"
#elif KMP_MIC1
#		undef KMP_ARCH_STR
#		define KMP_ARCH_STR "MIC1"
#define 
#endif

#if (defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP))
#		define KMP_ARCH_STR "WPhone"
#endif

#ifndef KMP_ARCH
#define KMP_ARCH KMP_ARCH_STR
#endif

// Detect library type (perf, stub).
#ifdef KMP_STUB
#define KMP_LIB_TYPE "stub"
#else
#define KMP_LIB_TYPE "performance"
#endif // KMP_LIB_TYPE

// Detect link type (static, dynamic).
#ifdef GUIDEDLL_EXPORTS
#define KMP_LINK_TYPE "dynamic"
#else
#define KMP_LINK_TYPE "static"
#endif // KMP_LINK_TYPE

// Finally, define strings.
#define KMP_LIBRARY   KMP_LIB_TYPE " library (" KMP_LINK_TYPE ")"
#define KMP_COPYRIGHT "Copyright (C) MindCodeTech (R) 2014 Extreme Tools for Software Computing."
#define KMP_COMPANY "(C) MindCodeTech (R) 2014 Extreme Tools for Software Computing."

/*
Using "magic" prefix in all the version strings is rather convenient to get static version info
from binaries by using standard utilities "strings" and "grep", e. g.:
$ strings libiomp5.so | grep "@(#)"
gives clean list of all version strings in the library. Leading zero helps to keep version 
string separate from printable characters which may occurs just before version string.
*/
#define KMP_VERSION_MAGIC_STR   "\x00@(#) "
#define KMP_VERSION_MAGIC_LEN   6                // Length of KMP_VERSION_MAGIC_STR.
#define KMP_VERSION_PREF_STR    "MindCodeTech(R) XOpenMP* "
#define KMP_VERSION_PREFIX      KMP_VERSION_MAGIC_STR KMP_VERSION_PREF_STR

KMP_GLOBALCONST int  __kmp_vers_date_str; const int __kmp_vers_date_str = KMP_BUILD_DDMM;

/* declare all the version string constants for KMP_VERSION env. variable */
KMP_GLOBALCONST int  __kmp_version_major;
KMP_GLOBALCONST int  __kmp_version_minor;
KMP_GLOBALCONST int  __kmp_version_build;
KMP_GLOBALCONST int  __kmp_openmp_version;
KMP_GLOBALCONST char __kmp_copyright[];    // Old variable, kept for compatibility with ITC and ITP.
KMP_GLOBALCONST char __kmp_version_copyright[];
KMP_GLOBALCONST char __kmp_version_lib_ver[];
KMP_GLOBALCONST char __kmp_version_lib_type[];
KMP_GLOBALCONST char __kmp_version_link_type[];
KMP_GLOBALCONST char __kmp_version_build_time[];
KMP_GLOBALCONST char __kmp_version_target_env[];
KMP_GLOBALCONST char __kmp_version_build_compiler[];
KMP_GLOBALCONST char __kmp_version_alt_comp[];
KMP_GLOBALCONST char __kmp_version_omp_api[];
// ??? KMP_GLOBALCONST char __kmp_version_debug[];
KMP_GLOBALCONST char __kmp_version_lock[];
KMP_GLOBALCONST char __kmp_version_perf_v19[];
KMP_GLOBALCONST char __kmp_version_perf_v106[];
KMP_GLOBALCONST char __kmp_version_nested_stats_reporting[];
KMP_GLOBALCONST char __kmp_version_ftnstdcall[];
KMP_GLOBALCONST char __kmp_version_ftncdecl[];
KMP_GLOBALCONST char __kmp_version_ftnextra[];

KMP_GLOBALAPI void KMP_CDECL __kmp_print_version_1(void);
KMP_GLOBALAPI void KMP_CDECL __kmp_print_version_2(void);

#ifdef __cplusplus
EXTERN_C_END
#endif // __cplusplus

#endif /* KMP_VERSION_H */
